#include "stdafx.h"
#include "Flight.h"
#include "Time.h"

using namespace std;

const int WAITING = -1;
const int BOARDING = 0;
const int FLYING = 1;
const int GRANTED = 1;
const int DENIED = 0;
const int INIT_FREQ = 1;

/*------------------------------------------------------------
/ Flight
/ Description: default constructor
/ Parameters: N/A
/ Return: N/A
------------------------------------------------------------*/
Flight::Flight(){
	Time* t;
	t = new Time(0,0);
	flightID = "";
	aircraftID = 0;
	scheduledDepartureTime = t; 
	scheduledArrivalTime = 0;
	departureGate = "";
	arrivalGate = "";
	delayAmount = 0;
	landingTime = 0;
	takeOffTime = 0;
	srcAirport = "";
	destAirport = "";
	approval = DENIED;
	frequency = INIT_FREQ;
}

/*------------------------------------------------------------
/ Flight
/ Description: constructor for creating outgoing Flight. 
/ Parameters: FlightID, AircraftID, scheduled dep time take off time,
				delay amount, setination airport
/ Return: N/A
------------------------------------------------------------*/
Flight::Flight(std::string _flightID, int _aircraftID, /*Time* _scheduledDepartureTime, */Time* _takeOffTime, string _departureGate, int _delayAmount, string destAP, int _freq){
	Time* t;
	t = new Time(0,0);
	flightID = _flightID;
	aircraftID = _aircraftID;
	scheduledDepartureTime = t;//_scheduledDepartureTime; 
	scheduledArrivalTime = t;
	departureGate = _departureGate;
	arrivalGate = "";
	delayAmount = _delayAmount;
	landingTime = t;
	takeOffTime = _takeOffTime;
	srcAirport = "";
	destAirport = destAP;
	incoming = false;
	approval = DENIED;
	frequency = _freq;
}

/*------------------------------------------------------------
/ Flight
/ Description: constructor for creating incoming Flight
/ Parameters: N/A
/ Return: N/A
------------------------------------------------------------*/
Flight::Flight(string _flightID, int _aircraftID, /*Time* _scheduledArrivalTime, */Time* _landingTime, string _arrivalGate, int _delayAmount, string srcAP, int _incoming, int _freq){
	Time* t;
	t = new Time(0,0);
	flightID = _flightID;
	aircraftID = _aircraftID;
	scheduledDepartureTime = t; 
	scheduledArrivalTime = t;//_scheduledArrivalTime;
	departureGate = "";
	arrivalGate = _arrivalGate;
	delayAmount = _delayAmount;
	landingTime = _landingTime;
	takeOffTime = t;
	srcAirport = srcAP;
	destAirport = "";
	incoming = _incoming;
	approval = DENIED;
	frequency = _freq;
}

/*------------------------------------------------------------
/ ~Flight
/ Description: default destructor
/ Parameters: N/A
/ Return: N/A
------------------------------------------------------------*/
Flight::~Flight(){

}

/*------------------------------------------------------------
/ getFlightID
/ Description: returns the Flight's unique identifier
/ Parameters: N/A
/ Return: string: Flight's unique identifier
------------------------------------------------------------*/
string Flight::getFlightID(){
	return flightID;
}

/*------------------------------------------------------------
/ setFlightID
/ Description: modifies the Flight's unique identifier
/ Parameters: string id: identifier being assigned to flight
/ Return: N/A
------------------------------------------------------------*/
void Flight::setFlightID(string id){
	flightID = id;
}

/*------------------------------------------------------------
/ getDepartureTime
/ Description: returns the Time at which the Flight is scheduled
/				to finish boarding and leave the gate
/ Parameters: N/A
/ Return: Time*: when the Flight is done boarding and leaves the gate
------------------------------------------------------------*/
Time* Flight::getDepartureTime(){
	return scheduledDepartureTime;

}

/*------------------------------------------------------------
/ getArrivalTime
/ Description: returns the Time at which the Flight is scheduled
/				to arrive at its allocated gate
/ Parameters: N/A
/ Return: Time*: when the Flight reaches its gate
------------------------------------------------------------*/
Time* Flight::getArrivalTime(){
	return scheduledArrivalTime;
}

/*------------------------------------------------------------
/ setLandingTime
/ Description: modifies the Time at which the Flight is scheduled
/				to arrive at the airport
/ Parameters: Time* _landingTime: when the Flight arrives at the airport
/ Return: N/A
------------------------------------------------------------*/
void Flight::setLandingTime(Time* _landingTime){
	landingTime = _landingTime;
}

/*------------------------------------------------------------
/ setTakeOffTime
/ Description: modifies the Time at which the Flight is scheduled
/				to leave the airport
/ Parameters: Time* _takeOffTime: when the Flight leaves the airport
/ Return: N/A
------------------------------------------------------------*/
void Flight::setTakeOffTime(Time* _takeOffTime){
	takeOffTime = _takeOffTime;
}

/*------------------------------------------------------------
/ getLandingTime
/ Description: returns the Time at which the Flight is scheduled
/				to land at the airport
/ Parameters: N/A
/ Return: Time: when the Flight arrives at the airport
------------------------------------------------------------*/
Time* Flight::getLandingTime(){
	return landingTime;
}

/*------------------------------------------------------------
/ getTakeOffTime
/ Description: returns the Time the Flight is scheduled to leave
/				the airport
/ Parameters: N/A
/ Return: Time: when the Flight leaves the airport
------------------------------------------------------------*/
Time* Flight::getTakeOffTime(){
	return takeOffTime;
}

/*------------------------------------------------------------
/ getDepartureGate
/ Description: returns the identifier for the gate from which
/				the Flight is departing
/ Parameters: N/A
/ Return: stand Identifier
------------------------------------------------------------*/
string Flight::getDepartureGate(){
	return departureGate;
}

/*------------------------------------------------------------
/ getArrivalGate
/ Description: returns the identifier for the gate at which 
/				the Flight is arriving
/ Parameters: N/A
/ Return: string: Flight`s arrival gate
------------------------------------------------------------*/
string Flight::getArrivalGate(){
	return arrivalGate;
}

/*------------------------------------------------------------
/ getDelayAmount
/ Description: returns the Flight's delay amount
/ Parameters: N/A
/ Return: Time: amount Flight has been delayed
------------------------------------------------------------*/
int Flight::getDelayAmount(){
	return delayAmount;
}

/*------------------------------------------------------------
/ increaseDelayAmount
/ Description: adds a Time to the amount of time a Flight
/				has been delayed
/ Parameters: Time t: the Time a Flight has been delayed
/ Return: N/A
------------------------------------------------------------*/
void Flight::increaseDelayAmount(int t){
	delayAmount += t;
}


/*------------------------------------------------------------
/ getStatus
/ Description: returns the status of the flight
/ Parameters: N/A
/ Return:the flight status
------------------------------------------------------------*/
int Flight::getStatus (){
	return flightStatus;
}

/*------------------------------------------------------------
/ setWaiting
/ Description: sets the status to waiting
/ Parameters: N/A
/ Return: N/A
------------------------------------------------------------*/
void Flight::setWaiting (){
	flightStatus = WAITING;
}

/*------------------------------------------------------------
/ setBoarding
/ Description: sets the status to boarding
/ Parameters: N/A
/ Return: N/A
------------------------------------------------------------*/
void Flight::setBoarding (){
	flightStatus = BOARDING;
}

/*------------------------------------------------------------
/ setFlying
/ Description: sets the status to flying
/ Parameters: N/A
/ Return: N/A
------------------------------------------------------------*/
void Flight::setFlying (){
	flightStatus = FLYING;
}

/*------------------------------------------------------------
/ getApprovalStatus
/ Description: check approval status of Flight
/ Parameters: N/A
/ Return: 1 if Flight is approved, 0 if Flight is not
------------------------------------------------------------*/
int Flight::getApprovalStatus(){
	return approval;
}

/*------------------------------------------------------------
/ grantApproval
/ Description: approves Flight to be added to Airport's schedule
/ Parameters: N/A
/ Return: N/A
------------------------------------------------------------*/
void Flight::grantApproval(){
	approval = GRANTED;
}

/*------------------------------------------------------------
/ denyApproval
/ Description: denies Flight from being added to Airport's schedule
/ Parameters: N/A
/ Return: N/A
------------------------------------------------------------*/
void Flight::denyApproval(){
	approval = DENIED;
}

int Flight::getAircraftID(){
	return aircraftID;
}

void Flight::setAircraftID(int _id){
	aircraftID = _id;
}

void Flight::setSrcAirport(string _airport){
	srcAirport.assign(_airport);
}

void Flight::setDestAirport(string _airport){
	destAirport.assign(_airport);
}

string Flight::getSrcAirport(){
	return srcAirport;
}

string Flight::getDestAirport(){
	return destAirport;
}

void Flight::setIncoming(int _incoming){
	incoming = _incoming;
}

int Flight::getIncoming(){
	return incoming;
}

AircraftType* Flight::getType(){
	return type;
}

void Flight::setType(AircraftType* _type){
	type = _type;
}

void Flight::setArrivalTime(Time* t){
	scheduledArrivalTime = t;
}

void Flight::setDepartureTime(Time* t){
	scheduledDepartureTime = t;
}